package main

import (
	"fmt"
	"math"
)

func main() {
	for i := 1; i <= 5; i++ {
		fmt.Println(judgeSquareSum(i))
	}
}

/**
 * @Description: 从0开始迭代，利用开平方对目标数做减法运算，若开平方后跟向下取整一样则说明存在，时间复杂度为O(根号c)
 */
func judgeSquareSum(c int) bool {
	for a := 0; a*a <= c; a++ {
		rt := math.Sqrt(float64(c - a*a))
		if rt == math.Floor(rt) {
			return true
		}
	}
	return false
}
